#pragma once

#include "Includes.h"


class Thread {
public:
	Thread();
	~Thread();

	// this method contains the code to be
	// executed by this thread
	virtual void run() = 0;

	// this method is to cause the thread to return
	// from its run() method gracefully.
	// Default implementation does nothing.
	virtual void stop();

	// starts the execution of this thread.
	void start();

	// suspend the calling thread until this thread returns
	// from its run() method
	void join();

	// use this method instead of Sleep()
	// A thread sleeping this way can be awakened via wakeUp().
	// Only use this inside your run() method
	void sleep(int milliseconds);

	// wake the Thread if it is sleeping
	void wakeUp();

private:
	HANDLE mHandle;
	HANDLE mEvent;
	static DWORD WINAPI threadFunc( void* thisptr);
};
